import { customerList, customerServiceLog } from "../../../api.js"
Page({
  data: {
    view: "contact",
    name:'',
    list:[],
    alert:false,
    nojj:false,
    alert_tit:'',
    alert_text:'',
    options:{}
  },
  onLoad(options) {
    var that = this
    this.setData({
      name: getApp().globalData.Store.user.name
    })
    customerList(getApp().globalData.businessId).then(res =>{
      if(res.data.code == 666){
        that.setData({
          list:res.data.data
        })
      }
    })    
    this.setData({
      options: options
    })
    console.log(this.data.options)
  },
  close(){
    this.setData({
      alert:false
    })
  },
  no_jj(){
    this.setData({
      alert: false,
      nojj:true,
    })
    var that = this
    setTimeout(function(){
      that.setData({
        nojj: false,
      })
    },1500)
  },
  alert(e){
    var index = e.currentTarget.dataset.num
    var that = this
    that.setData({
      alert:true,
      alert_tit: that.data.list[index].title,
      alert_text: that.data.list[index].content
    })
  },
  onShow() {
    getApp().startpage(new Date().getTime())
  },
  onHide() {
    getApp().endpage(new Date().getTime())
  },
  kefub(){
    var yp = this.data.options
    if (yp.type != 1){
      customerServiceLog(
        getApp().globalData.Store.token,
        yp.type
      ).then(res => {

      })
    }else{
      customerServiceLog(
        getApp().globalData.Store.token,
        1,
        yp.prod_id
      ).then(res => {
        
      })
    }
  }
})